<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveSupport::Testing::Isolation::Subprocess</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveSupport::Testing::Isolation::Subprocess 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/activesupport/lib/active_support/testing/isolation_rb.html">activesupport/lib/active_support/testing/isolation.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Subprocess.html#method-i-run_in_isolation">run_in_isolation</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class="attr-name">ORIG_ARGV</td>
            <td>=</td>
            <td class="attr-value">ARGV.dup unless defined?(ORIG_ARGV)</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
      </table>
    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-run_in_isolation">
            
              <b>run_in_isolation</b>(&amp;blk)
            
            <a href="Subprocess.html#method-i-run_in_isolation" name="method-i-run_in_isolation" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Crazy H4X to get this working in windows / jruby with no forking.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-run_in_isolation_source')" id="l_method-i-run_in_isolation_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/1a9109879aa4ba840b17d0dac780ad66dbb15968/activesupport/lib/active_support/testing/isolation.rb#L111" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-run_in_isolation_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/testing/isolation.rb, line 111</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">run_in_isolation</span>(&amp;<span class="ruby-identifier">blk</span>)
  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;tempfile&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;ISOLATION_TEST&quot;</span>]
    <span class="ruby-identifier">proxy</span> = <span class="ruby-constant">ProxyTestResult</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">retval</span> = <span class="ruby-keyword">yield</span> <span class="ruby-identifier">proxy</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;ISOLATION_OUTPUT&quot;</span>], <span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">file</span>.<span class="ruby-identifier">puts</span> [<span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>([<span class="ruby-identifier">retval</span>, <span class="ruby-identifier">proxy</span>])].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&quot;m&quot;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">exit!</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;isolation&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tmpfile</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;ISOLATION_TEST&quot;</span>]   = <span class="ruby-ivar">@method_name</span>
      <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;ISOLATION_OUTPUT&quot;</span>] = <span class="ruby-identifier">tmpfile</span>.<span class="ruby-identifier">path</span>

      <span class="ruby-identifier">load_paths</span> = <span class="ruby-identifier">$-I</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;-I\&quot;#{File.expand_path(p)}\&quot;&quot;</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>)
      <span class="ruby-node">%x#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(&quot; &quot;)} -t\&quot;#{self.class}\&quot;`</span>

      <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;ISOLATION_TEST&quot;</span>)
      <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;ISOLATION_OUTPUT&quot;</span>)

      <span class="ruby-keyword">return</span> <span class="ruby-identifier">tmpfile</span>.<span class="ruby-identifier">read</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&quot;m&quot;</span>)[<span class="ruby-number">0</span>]
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    